package com.dhms.vostok1.data.fault

import com.dhms.vostok1.data.BasePageQueryData
import com.dhms.vostok1.data.DEFAULT_PAGE_LIMIT
import com.dhms.vostok1.data.DEFAULT_PAGE_OFFSET
import com.squareup.moshi.Json

/**
{
"status": 200,
"message": "ok",
"data": {
"faults": [
{
"fa_id": 500020000004753,
"fa_supervisor_id": 0,
"fa_producer_id": 0,
"fa_consumer_id": 500020000016,
"fa_device_id": 19,
"fa_metric_no": "m.1797",
"fa_fault_type_id": 2000000,
"fa_fault_level_no": 1,
"fa_occurred": "2022-06-27 10:15:50",
"fa_last_occurred": "2022-06-27 10:15:50",
"fa_occurred_times": 1,
"fa_occurred_steps": "3.338,1,1656296150",
"fa_expires": "2022-06-27 22:15:50",
"fa_state": "occurred",
"fa_accept_user_name": "",
"fa_handle_user_id": 0,
"fa_handle_user_name": "",
"fa_handle_elapsed": 0,
"fa_description": "--",
"fa_handle_comment": null,
"fa_value": "3.338",
"fa_min_value": "3.338",
"fa_max_value": "3.338",
"fa_source": 0,
"fa_diagnosis_supported": 0,
"fa_vibfilename": "/oss/assets/vib/19/m.1797/2022/06/19-m.1797-2022-06-27T10-15-50.gz",
"fa_is_enabled": "yes",
"fa_extending": {},
"ft_type": "智能告警",
"fl_level": "一般",
"fl_background_color": "#f3b82c",
"param_name": "振动加速度",
"part_id": null,
"part_name": null,
"pa_thresholds": "3,4,5,6",
"pa_thresholds_ext": "",
"tpmp_id": null,
"tpmp_name": null,
"cp_id": 500020000549,
"cp_name": "autotest_cp1",
"spc_item_name": "",
"spc_item_standard": "",
"spc_item_group_id": 0,
"spc_item_test_way": null,
"spc_item_test_way_ext": "",
"spc_item_result_type": 0,
"spc_item_group_name": ""
}]
}
}
 */
data class RelatedFaultListItemData(
    @Json(name = "fa_id")
    val faId: Long,
    @Json(name = "fa_metric_no")
    val metricNo: String?,
    @Json(name = "fa_occurred")
    val faOccurred: String?,
    @Json(name = "fa_value")
    val faValue: String?,
    @Json(name = "fl_level")
    val flLevel: String?,
    @Json(name = "pa_threshold")
    val paThreshold: Float?,
    @Json(name = "pa_thresholds")
    val paThresholds: String?,
    @Json(name = "fa_occurred_steps")
    val faOccurredSteps: String?,
)

data class RelatedFaultListQueryData(
    @Json(name = "de_id") var deviceId: Long? = null,
    @Json(name = "time_from") var occurredStart: String? = null,
    @Json(name = "time_to") var occurredEnd: String? = null,
    override var limit: Int = DEFAULT_PAGE_LIMIT,
    override val offset: Int = DEFAULT_PAGE_OFFSET,
) : BasePageQueryData

data class RelatedFaultListData(
    @Json(name = "faults")
    val items: List<RelatedFaultListItemData>?,
)

typealias RelatedFaultResData = RelatedFaultListData